<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    var canJump = function(nums) {
        if (nums.length === 1 && nums[0] === 0) return true;
        // 可以跳跃的最远位置
        let max = 0;
        for(let i = 0; i< nums.length; ++i) {
            if(max < i) {
                console.log(max)
                console.log(i)
                return false;
            }
            max = Math.max(max, nums[i]+i);
            // console.log("max",max)
        }
        return true;
    };
    console.log(canJump([3,2,1,0,4]))
</script>
</body>
</html>
